<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-08-31 16:23:37
 * @LastEditors: voanit
 * @LastEditTime: 2022-08-31 18:28:09
-->
<script setup>
/* 实现添加数据
1-绑定键盘弹起事件
  1-1 获取表单值
    1-1-1 定义初始表单值
    1-1-2 v-model=’定义初始表单值‘
  1-2 子向父传值 传递表单值
2-绑定事件获取传递过来的值并将值追加到数组中   app
*/
import { ref, computed } from 'vue'
const val = ref('')

/* 实现全选和反选 */
const props = defineProps({
  list: {
    type: Array,
    default: () => []
  }
})


const emit = defineEmits(['addHandle'])
const add = () => {
  emit('addHandle', val.value)
  val.value = ''
}


</script>

<template>
  <header class="header">
    <h1>todos===</h1>
    <input v-model="val" @keyup.enter="add" class="new-todo" placeholder="What needs to be done?" autofocus />
  </header>
</template>

<style lang="less" scoped>
</style>
